<?php
class Template extends CI_Controller{
	public function __construct(){
		parent::__construct();
	}
	public function index(){
				
		$temp["template"] = "administrator/template/list";
		$this->load->model("administrator/Mdtemplate");
		$temp["data"] = $this->Mdtemplate->listTemplate();
		$this->load->view("administrator/index",$temp);

	}
	public function add(){
		$temp["template"] = "administrator/template/add";
		$temp["data"] = "add template";
		$this->load->view("administrator/index",$temp);
	}
	
	public function edit($project_id){
		$temp["template"] = "administrator/template/edit";
		$this->load->model("administrator/Mdtemplate");
		
		$temp["data"] = $this->Mdtemplate->templateById($project_id);
		$this->load->view("administrator/index",$temp);		
		
	}
	public function saveTemplate(){
		$data=array();
		$data = $this->input->post("templatesContentData");		
		$this->load->model("administrator/Mdtemplate");
		
		if($this->input->post("editsubmit")!="")
		{ 
			//if($this->input->server('REQUEST_METHOD') == 'POST') 
			$project_id = $this->input->post("project_id");			
			$this->Mdtemplate->updateTemplate($project_id,$data);
			redirect(base_url()."administrator/template/index");
			//$this->index();
		}
		if($this->input->post("addsubmit")!="")
		{ 
			$this->Mdtemplate->addTemplate($data);
			redirect(base_url()."administrator/template/index");
			//$this->index();
		}
	}
	public function deleteTemplateAction($project_id){
		$this->load->model("administrator/Mdtemplate");
		$this->Mdtemplate->deleteTemplate($project_id);
		$this->index();
	}
	/*public function addTemplate(){
		if($this->input->post("addsubmit"))
		{ 
			$data=array();
			$data = $this->input->post("templatesContentData");		
			$this->load->model("administrator/Mdtemplate");
			$this->Mdtemplate->addTemplate($data);
			$this->index();
		}
		
	}*/
} 